<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>


        <ui:composition template="./../../Template/generalTemplate.xhtml">

            <ui:define name="content">

                <h:form id="form4" prependId="false">
                    <f:view beforePhase="#{viewFinalGoodsInventoryManagedBean.initView}">
                        <p:panel id="finalGoods" header="View Final Good Inventory" style="height:495px;">
                            <div style="margin-left:50px;margin-right:50px;margin-top:30px;">


                                <p:dataTable id="FGinventory" value="#{viewFinalGoodsInventoryManagedBean.getProductInventories()}" var="FGinventoryList" paginator="true" rows="6">
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Proudct" />
                                        </f:facet>
                                        <h:outputText value="#{FGinventoryList.product.productName}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Incoming quantity" />
                                        </f:facet>
                                        <h:outputText value="#{FGinventoryList.incomingQty}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Current Inventory Level" />
                                        </f:facet>
                                        <h:outputText value="#{FGinventoryList.currentLevel}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Reserved Quantity"/>
                                        </f:facet>
                                        <h:outputText value="#{FGinventoryList.reservedQty}" />
                                    </p:column>

                                    <p:column style="width:65px;text-align:center;">
                                        <f:facet name="header">View Records</f:facet>

                                        <p:commandButton update=":form4:display" oncomplete="viewDetailsDialog.show()" image="ui-icon ui-icon-search" title="View"  >
                                            <f:setPropertyActionListener value="#{FGinventoryList}" target="#{viewFinalGoodsInventoryManagedBean.selectedInventory}" />  

                                        </p:commandButton>
                                    </p:column>  



                                </p:dataTable>

                                <p:commandButton value="Edit" ajax="false" actionListener="#{viewFinalGoodsInventoryManagedBean.gotoEdit}" rendered="#{viewFinalGoodsInventoryManagedBean.canEdit}"/>

                                <br />

                                <p:dialog header="Inventory Detail" widgetVar="viewDetailsDialog" resizable="false" id="viewDetails" showEffect="fade" hideEffect="explode" modal="true" width="700">  

                                    <h:panelGrid id="display" cellpadding="0" style="margin:0 auto;"> 

                                        <p:dataTable id="recordDetail" dynamic="true"   value="#{viewFinalGoodsInventoryManagedBean.selectedInventory.productBatchRecords}" var ="recordList" >

                                            <p:column>
                                                <f:facet name="header">Batch Record Id</f:facet>
                                                #{recordList.id}
                                            </p:column>

                                            <p:column>
                                                <f:facet name="header">Manufacture Date</f:facet>
                                                <h:outputText value="#{recordList.manufactureDate}" >
                                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                                </h:outputText>

                                            </p:column> 

                                            <p:column>
                                                <f:facet name="header"> Quantity</f:facet>
                                                #{recordList.quantity}
                                            </p:column> 
                                            <p:column>
                                                <f:facet name="header">Warehouse Location</f:facet>
                                                #{recordList.productInventoryLevel.product.warehouseLocation}
                                            </p:column> 
                                            <p:column>
                                                <f:facet name="header">Reserved Status</f:facet>
                                                <h:outputText style="color:red;" value="Reserved" rendered="#{recordList.reserved}"/>
                                                <h:outputText style="color:blue;" value="Not Reserved" rendered="#{!recordList.reserved}"/>
                                            </p:column> 



                                        </p:dataTable>



                                    </h:panelGrid>
                                </p:dialog>
                            </div>
                        </p:panel>
                    </f:view>
                </h:form>

            </ui:define>

        </ui:composition>



    </body>
</html>
